package com.syezon.wifikey.news;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.syezon.wifikey.R;
import com.syezon.wifikey.base.BaseFragment;
import com.syezon.wifikey.speedup.SpeedUpConfig;
import com.syezon.wifikey.speedup.SpeedUpHelper;
import com.syezon.wifikey.utils.WifiUtil;

import butterknife.BindView;
import butterknife.OnClick;

public class WifiInfoFragment extends BaseFragment {

    private static final String ARG_SSID = "ssid";

    @BindView(R.id.tv_ssid)
    TextView mTvSsid;

    public WifiInfoFragment() {
    }


    public static WifiInfoFragment newInstance(String ssid) {
        WifiInfoFragment fragment = new WifiInfoFragment();
        Bundle args = new Bundle();
        args.putString(ARG_SSID, ssid);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.app_news_layout_wifi_info_result;
    }

    @Override
    protected void initViewsAndEvents() {
        Bundle arguments = getArguments();
        if (arguments != null) {
            String ssid = arguments.getString(ARG_SSID, "");
            mTvSsid.setText(ssid);
        }
    }

    @OnClick({R.id.tv_speedup})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_speedup:
                String ssid = WifiUtil.getWifiSSID();
                if (TextUtils.isEmpty(ssid)) {
                    SpeedUpHelper.speedUp(mContext, ssid, SpeedUpConfig.getCurrentScore(ssid), SpeedUpConfig.getCurrentAddPercent(ssid));
                }
                break;
        }
    }
}
